//
//  UIImageView+imageName.m
//  SmartHome
//
//  Created by Jekin on 2018/12/27.
//  Copyright © 2018 liumaoqiang. All rights reserved.
//

#import "UIImage+imageName.h"
#import <objc/runtime.h>
@implementation UIImage (imageName)
+(void)load {
    Method imageNameMethod = class_getClassMethod([self class], @selector(imageNamed:));
    Method sm_imageNamedMethod = class_getClassMethod([UIImage class], @selector(sm_imageNamed:));
    method_exchangeImplementations(imageNameMethod, sm_imageNamedMethod);
}

+ (UIImage *)sm_imageNamed:(NSString  *)imageName {
    UIImage *image = [self sm_imageNamed:imageName];
    image.sm_imageName = imageName;
    return image;
}

- (void)setSm_imageName:(NSString * _Nullable)sm_imageName {
    objc_setAssociatedObject(self, @selector(sm_imageName), sm_imageName, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

- (NSString *)sm_imageName {
    return objc_getAssociatedObject(self, _cmd);
}


@end
